package com.honor.games.wg.entities;


public class WGBoard {

	private int boardTilesWidthNumber = 0;
	private int boardTilesHeightNumber = 0;
	
	private boolean tileSelected = false;
	private WGTile selectedTile;

	private WGTile[][] tiles;

	public WGBoard(int boardTilesWidthNumber, int boardTilesHeightNumber) {
		this.boardTilesWidthNumber = boardTilesWidthNumber;
		this.boardTilesHeightNumber = boardTilesHeightNumber;
		tiles = new WGTile[boardTilesHeightNumber][boardTilesWidthNumber];
		
		initialize();
		loadMap();
	}

	private void initialize() {
		for (int i = 0; i < boardTilesHeightNumber; i++) {
			for (int j = 0; j < boardTilesWidthNumber; j++) {
				tiles[i][j] = new WGTile(WGTileType.GROUND, j, i);
			}
		}
	}

	public void loadMap() {
		tiles[5][1].setTileType(WGTileType.WATER);
		tiles[1][13].setTileType(WGTileType.WATER);
		tiles[2][0].setTileType(WGTileType.TREE);
		tiles[2][1].setTileType(WGTileType.TREE);
		tiles[5][6].setTileType(WGTileType.TREE);
		tiles[1][9].setTileType(WGTileType.TREE);
		tiles[1][10].setTileType(WGTileType.TREE);
		tiles[0][9].setTileType(WGTileType.TREE);
	}

	public WGTile[][] getTiles() {
		return tiles;
	}

	public boolean isTileSelected() {
		return tileSelected;
	}

	public void setTileSelected(int tileX, int tileY) {
		this.tileSelected = true;
		this.selectedTile = tiles[tileY][tileX];
	}
	
	public void unselect() {
		tileSelected = false;
		this.selectedTile = null;
	}
	
	public WGTile getSelectedTile() {
		return selectedTile;
	}
}
